#define  _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
typedef struct Stu {
	char name[20];
	int age;
	double score;
}stu;
void printf_arr(int arr[],int size)
{
	int i = 0;
	for (i = 0; i < size; i++)
		printf("%d", arr[i]);
}
int cmp_int(const void *e1,const void* e2)
{
	return (*(int*)e1 - *(int*)e2);
}
int cmp_stu_by_age(const void* e1,const void* e2)
{
	return ((stu*)e1)->age - ((stu*)e2)->age;
}
int cmp_stu_by_name(const void* e1,const void* e2)
{
	return strcmp(((stu*)e1)->name, ((stu*)e2)->name);
}
void Swap(char *buf1,char* buf2,int width)
{
	int i = 0;
	for (i = 0; i < width; i++)
	{
		char tmp = *buf1;
		*buf1 = *buf2;
		*buf2 = tmp;
		buf1++;
		buf2++;
	}
}
void Swap(char* buf1,char* buf2,int width)
{
	int i = 0;
	for (i = 0; i < width; i++)
	{
		char tmp = *buf1;
		*buf1 = *buf2;
		*buf2 = tmp;
		*buf1++;
		*buf2++;
	}
}
void Swap(char* buf1,char* buf2,int width)
{
	int i = 0;
	for (i = 0; i < width; i++)
	{
		char tmp = *buf1;
		*buf1 = *buf2;
		*buf2 = tmp;
		*buf1++;
		*buf2++;
	}
}
void bubble_sort(void* base,int num,int width,int(*cmp)(const void* e1,const void* e2))
{
	int i = 0;
	for (i = 0; i < num - 1; i++)
	{
		int j = 0;
		for (j = 0; j < num - i - 1; j++)
		{
			if (cmp((char*)base + j * width, (char*)base + (j + 1) * width))
				Swap((char*)base + j * width, (char*)base + (j + 1) * width,width);
		}
	}
}
void bubble_sort(void* base,int num,int width,int(*cmp)(const void* e1,const void* e2))
{
	int i = 0;
	for (i = 0; i < num - 1; i++)
	{
		int j = 0;
		for (j = 0; j < num - i - 1; j++)
		{
			if (cmp((char*)base + j * width, (char*)base + (j + 1) * width))
				Swap((char*)base + j * width, (char*)base + (j + 1) * width,width);
		}
	}
}